package pers.cz.pub;

import pers.cz.cache.BaseDataCache;
import pers.cz.log.LogUtils;

/**
 * 公共抽象业务类
 * @program: PostGirl-panent
 * @description: AbstractBusiness
 * @author: Cheng Zhi
 * @create: 2021-03-10 10:04
 **/
public abstract class AbstractBusiness {

    public static final int SDL_ONCE = 1;
    // 日志工具
    public LogUtils logUtils = new LogUtils(this.getClass());

    // springBean工具
    public BeanHelper helper;

    // 公共参数
    protected CpublicFunc cPublicFunc;

    // 缓存
    protected BaseDataCache baseDataCache;

    public CpublicFunc getcPublicFunc() {
        return cPublicFunc;
    }

    public void setcPublicFunc(CpublicFunc cPublicFunc) {
        this.cPublicFunc = cPublicFunc;
    }

    public void setMapper(BeanHelper helper) {
        this.helper = helper;

        if (cPublicFunc == null) {
            this.cPublicFunc = new CpublicFunc(this.helper);
        }

        if (baseDataCache == null) {
            this.baseDataCache = new BaseDataCache(this.helper);
        }
    }

    public BeanHelper getMapper() {
        return helper;
    }

    public final <T> T getMapper(Class<T> t){
        return helper.getBean(t);
    }

}
